package com.springboot.middleware.middleware_redisson.model.mapper;

import com.springboot.middleware.middleware_redisson.model.entity.BookStock;
import com.springboot.middleware.middleware_redisson.model.entity.BookStockExample;

import java.util.List;

import com.springboot.middleware.middleware_redisson.server.dto.BookRobDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

@Mapper
public interface BookStockMapper {
    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table book_stock
     *
     * @mbg.generated Mon Jan 31 07:06:17 CST 2022
     */
    long countByExample(BookStockExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table book_stock
     *
     * @mbg.generated Mon Jan 31 07:06:17 CST 2022
     */
    int deleteByExample(BookStockExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table book_stock
     *
     * @mbg.generated Mon Jan 31 07:06:17 CST 2022
     */
    int deleteByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table book_stock
     *
     * @mbg.generated Mon Jan 31 07:06:17 CST 2022
     */
    int insert(BookStock record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table book_stock
     *
     * @mbg.generated Mon Jan 31 07:06:17 CST 2022
     */
    int insertSelective(BookStock record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table book_stock
     *
     * @mbg.generated Mon Jan 31 07:06:17 CST 2022
     */
    List<BookStock> selectByExample(BookStockExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table book_stock
     *
     * @mbg.generated Mon Jan 31 07:06:17 CST 2022
     */
    BookStock selectByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table book_stock
     *
     * @mbg.generated Mon Jan 31 07:06:17 CST 2022
     */
    int updateByExampleSelective(@Param("record") BookStock record, @Param("example") BookStockExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table book_stock
     *
     * @mbg.generated Mon Jan 31 07:06:17 CST 2022
     */
    int updateByExample(@Param("record") BookStock record, @Param("example") BookStockExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table book_stock
     *
     * @mbg.generated Mon Jan 31 07:06:17 CST 2022
     */
    int updateByPrimaryKeySelective(BookStock record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table book_stock
     *
     * @mbg.generated Mon Jan 31 07:06:17 CST 2022
     */
    int updateByPrimaryKey(BookStock record);

    /**
     * 通过bookNo获取BookStock
     *
     * @param bookNo bookNo
     * @return bookStock
     */
    BookStock selectByBookNo(String bookNo);

    /**
     * 将bookNo对应的书籍的库存减1
     * @param bookNo 书籍号
     * @return 更新行数
     */
    int updateStockWithLock(String bookNo);
}